import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaProfesor extends javax.swing.JFrame {
	private JPanel jPanel1;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JLabel jLabel5;
	private JTextField txtNombre;
	private JButton btnRegistrar;
	private JTextField txtTitulo;
	private JTextField txtApellido;
	private JTextField txtCedula;
	private JLabel jLabel6;
	private JLabel jLabel2;
	private JLabel jLabel1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	/*public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VistaProfesor inst = new VistaProfesor();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}*/
	
	public VistaProfesor(Seccion seccion) {
		super();
		initGUI(seccion);		
	}
	
	
	public void  datosProfesor(Seccion seccion) throws IOException
	{
		seccion.asignarProfesor(txtCedula.getText(), txtNombre.getText(), txtApellido.getText(), txtTitulo.getText());
		JOptionPane.showMessageDialog(null, "El profesor ha sido asignado", "Sistema", JOptionPane.INFORMATION_MESSAGE);
		txtCedula.setEnabled(false);
		txtNombre.setEnabled(false);
		txtApellido.setEnabled(false);
		txtTitulo.setEnabled(false);
		btnRegistrar.setEnabled(false);
	}
	
	private void initGUI(final Seccion seccion) {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1, BorderLayout.CENTER);
				{
					jLabel1 = new JLabel();
					jPanel1.add(jLabel1);
					jLabel1.setText("Cedula: ");
					jPanel1.setLayout(null);
					jPanel1.setPreferredSize(new java.awt.Dimension(289, 272));
					jPanel1.setBackground(new java.awt.Color(255,255,255));
				}
				{
					jLabel2 = new JLabel();
					jPanel1.add(jLabel2);
					jLabel2.setText("Cedula: ");
					jLabel2.setBounds(19, 44, 73, 14);
				}
				{
					jLabel3 = new JLabel();
					jPanel1.add(jLabel3);
					jLabel3.setText("Nombre: ");
					jLabel3.setBounds(19, 79, 57, 14);
				}
				{
					jLabel4 = new JLabel();
					jPanel1.add(jLabel4);
					jLabel4.setText("Nombre: ");
					jLabel4.setBounds(19, 79, 69, 14);
				}
				{
					jLabel5 = new JLabel();
					jPanel1.add(jLabel5);
					jLabel5.setText("Apellido: ");
					jLabel5.setBounds(19, 116, 74, 14);
				}
				{
					jLabel6 = new JLabel();
					jPanel1.add(jLabel6);
					jLabel6.setText("Titulo: ");
					jLabel6.setBounds(19, 153, 68, 14);
				}
				{
					txtCedula = new JTextField();
					jPanel1.add(txtCedula);
					txtCedula.setBounds(104, 41, 155, 21);
				}
				{
					txtNombre = new JTextField();
					jPanel1.add(txtNombre);
					txtNombre.setBounds(106, 76, 155, 21);
				}
				{
					txtApellido = new JTextField();
					jPanel1.add(txtApellido);
					txtApellido.setBounds(105, 113, 155, 21);
				}
				{
					txtTitulo = new JTextField();
					jPanel1.add(txtTitulo);
					txtTitulo.setBounds(105, 150, 155, 21);
				}
				{
					btnRegistrar = new JButton();
					jPanel1.add(btnRegistrar);
					btnRegistrar.setText("Registrar");
					btnRegistrar.setBounds(60, 191, 110, 20);
					btnRegistrar.setBackground(new java.awt.Color(173,216,230));
				}
			}
			

			btnRegistrar.addActionListener(new ActionListener() {

				public void actionPerformed(ActionEvent evt) {
										
					try {
						
						datosProfesor(seccion);
								
						
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					
					
				}
			});
			
			this.setTitle("Profesor");
			this.setLocationRelativeTo(null);
			this.setVisible(true);
			pack();
			this.setSize(300, 302);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}


}
